import { Controller, Get, Post,Req, Body, Request } from '@nestjs/common';
import { AuthService } from '../services/auth.service';
import { rejects } from 'assert';
import { from } from 'rxjs';



@Controller('auth')
export class AuthController {

  constructor(
    private authService: AuthService
  ) { }


  /**
  * 登录
  * @param query 
  */
  @Post('/login')
  login(@Body() body,@Req() req) {
    return  this.authService.login(body,req);
  }

  /**
   * 退出登录
   */
  @Post('/logout')
  logout(@Body() body, @Request() req) {
    const token = req.headers.authorization;
    return this.authService.logout(token);
  }

  /**
   * 刷新token
   */
  @Post('/refreshToken')
  refreshToken(@Body() body){
    return this.authService.refreshToken(body);
  }

}
